<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Services\Guzzle;

class AuthController extends Controller
{

    public function getToken()
    {
        $Guzzle = new Guzzle();
        $account = config('app.app_npn');
        $password = base64_decode(config('app.app_npn_key'));
        $json = array('name' => $account, 'password' => $password);
        $userinfo = $Guzzle->guzzle_post(config('app.boss_api_url'), '/v2/login', $json, ['Content-type' => 'application/json'], 'json');
        if ($userinfo['status'] == 'error') {
            return $userinfo;
        }
        return $userinfo['token'];
    }
}